﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Utility
{

    /************************************************************************/
    /* 发送邮件帮助类                                                                     */
    /************************************************************************/
    public class EmailHelper
    {


        
        public static void sendMail(string name, string pass, string email, string body, string subject)
        {
            try
            {
                string Email = email;   //电子邮件地址
                //电子邮件的内容
                //string body = "您好亲爱的‘" + name + "’您的密码为：'" + pass + "'";
                //sstring subject = name + "，欢迎您的再次光临！";  //邮件的主题

                System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
                //这里使用QQ的邮箱来发送测试，如果是其它邮箱，请根据其它邮箱POP3/IMAP/SMTP服务来设置  

                client.Host = "smtp.163.com";
                client.UseDefaultCredentials = false;
                client.Credentials = new System.Net.NetworkCredential("tewind", "9169o69k");
                client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage("tewind@163.com", Email);
                message.Subject = subject;
                message.Body = body;
                message.BodyEncoding = System.Text.Encoding.UTF8;
                message.IsBodyHtml = true;

                try
                {
                    client.Send(message);
                    //已发送确认邮件到您的邮箱
                }
                catch
                {
                }

            }
            catch (Exception ex)
            {
                //邮箱不存在
            }
        }

    }
}
